
// 函数
// --------------------------------------------------

.scrollable() {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

// set one px
// --------------------------------------------------

.setTopLine(@c: #C7C7C7) {
  content: " ";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 1px;
  border-top: 1px solid @c;
  color: @c;
  transform-origin: 0 0;
  transform: scaleY(0.5);
}

.setBottomLine(@c: #C7C7C7) {
  content: " ";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  border-bottom: 1px solid @c;
  color: @c;
  transform-origin: 0 100%;
  transform: scaleY(0.5);
}

.setLeftLine(@c: #C7C7C7) {
  content: " ";
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 100%;
  border-left: 1px solid @c;
  color: @c;
  transform-origin: 0 0;
  transform: scaleX(0.5);
}

.setRightLine(@c: #C7C7C7) {
  content: " ";
  position: absolute;
  right: 0;
  top: 0;
  width: 1px;
  height: 100%;
  border-right: 1px solid @c;
  color: @c;
  transform-origin: 100% 0;
  transform: scaleX(0.5);
}

.flexbox() {
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
}

.flex-wrap(@fw) when (@fw = nowrap) {
  -webkit-box-lines: single;
  -moz-box-lines: single;
  -webkit-flex-wrap: nowrap;
  -ms-flex-wrap: none;
  -ms-flex-wrap: nowrap;
  flex-wrap: nowrap;
}

.flex-wrap(@fw) when (@fw = wrap) {
  -webkit-box-lines: multiple;
  -moz-box-lines: multiple;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
}

.flex-wrap(@fw) when not (@fw = wrap) and not (@fw = nowrap) {
  -webkit-flex-wrap: @fw;
  -ms-flex-wrap: @fw;
  flex-wrap: @fw;
}

.flex-shrink(@fs) {
  -webkit-flex-shrink: @fs;
  -ms-flex: 0 @fs auto;
  flex-shrink: @fs;
}

.justify-content(@jc) when (@jc = flex-start) {
  -webkit-box-pack: start;
  -ms-flex-pack: start;
  -webkit-justify-content: flex-start;
  justify-content: flex-start;
}

.justify-content(@jc) when (@jc = flex-end) {
  -webkit-box-pack: end;
  -ms-flex-pack: end;
  -webkit-justify-content: flex-end;
  justify-content: flex-end;
}

.justify-content(@jc) when (@jc = space-between) {
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
}

.justify-content(@jc) when not (@jc = flex-start) and not (@jc = flex-end) and not (@jc = space-between) {
  -webkit-box-pack: @jc;
  -ms-flex-pack: @jc;
  -webkit-justify-content: @jc;
  justify-content: @jc;
}

.align-items(@ai) when (@ai = flex-start) {
  -webkit-box-align: start;
  -ms-flex-align: start;
  -webkit-align-items: flex-start;
  align-items: flex-start;
}

.align-items(@ai) when (@ai = flex-end) {
  -webkit-box-align: end;
  -ms-flex-align: end;
  -webkit-align-items: flex-end;
  align-items: flex-end;
}

.align-items(@ai) when not (@ai = flex-start) and not (@ai = flex-end) {
  -webkit-box-align: @ai;
  -ms-flex-align: @ai;
  -webkit-align-items: @ai;
  align-items: @ai;
}

.align-content(@ai) {
  -ms-flex-line-pack: @ai;
  -webkit-align-content: @ai;
  align-content: @ai;
}

.align-self(@as) {
  -ms-flex-item-align: @as;
  -webkit-align-self: @as;
  align-self: @as;
}

.clearfix() {
  &:before,
  &:after {
    content: " ";
    display: table;
  }
  &:after {
    clear: both;
  }
}

.hairline(@position, @color) when (@position = top) {
  &:before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: auto;
    right: auto;
    height: 1px;
    width: 100%;
    background-color: @color;
    display: block;
    z-index: 15;
    transform-origin: 50% 0%;
    @media only screen and (-webkit-min-device-pixel-ratio: 2) {
      transform: scaleY(0.5);
    }
    @media only screen and (-webkit-min-device-pixel-ratio: 3) {
      transform: scaleY(0.33);
    }
  }
}

.hairline(@position, @color) when (@position = left) {
  &:before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: auto;
    right: auto;
    width: 1px;
    height: 100%;
    background-color: @color;
    display: block;
    z-index: 15;
    transform-origin: 0% 50%;
    @media only screen and (-webkit-min-device-pixel-ratio: 2) {
      transform: scaleY(0.5);
    }
    @media only screen and (-webkit-min-device-pixel-ratio: 3) {
      transform: scaleY(0.33);
    }
  }
}

.hairline(@position, @color) when (@position = bottom) {
  &:after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    right: auto;
    top: auto;
    height: 1px;
    width: 100%;
    background-color: @color;
    display: block;
    z-index: 15;
    transform-origin: 50% 100%;
    @media only screen and (-webkit-min-device-pixel-ratio: 2) {
      transform: scaleY(0.5);
    }
    @media only screen and (-webkit-min-device-pixel-ratio: 3) {
      transform: scaleY(0.33);
    }
  }
}

.hairline(@position, @color) when (@position = right) {
  &:after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    left: auto;
    bottom: auto;
    width: 1px;
    height: 100%;
    background-color: @color;
    display: block;
    z-index: 15;
    transform-origin: 100% 50%;
    @media only screen and (-webkit-min-device-pixel-ratio: 2) {
      transform: scaleY(0.5);
    }
    @media only screen and (-webkit-min-device-pixel-ratio: 3) {
      transform: scaleY(0.33);
    }
  }
}

// For right and bottom
.hairline-remove(@position) when not (@position = left) and not (@position = top) {
  &:after {
    display: none;
  }
}

// For left and top
.hairline-remove(@position) when not (@position = right) and not (@position = bottom) {
  &:before {
    display: none;
  }
}

// For right and bottom
.hairline-color(@position, @color) when not (@position = left) and not (@position = top) {
  &:after {
    background-color: @color;
  }
}

// For left and top
.hairline-color(@position, @color) when not (@position = right) and not (@position = bottom) {
  &:before {
    background-color: @color;
  }
}

// Encoded SVG Background
.encoded-svg-background(@svg) {
  @url: `encodeURIComponent(@{svg})`;
  background-image: url("data:image/svg+xml;charset=utf-8,@{url}");
}

// Preserve3D
.preserve3d() {
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  -ms-transform-style: preserve-3d;
  transform-style: preserve-3d;
}

//from ratchet
.linear-gradient(@color-from, @color-to) {
  background-color: @color-from; // Old browsers
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, @color-from), color-stop(100%, @color-to)); // Chrome, Safari4+
  background-image: -webkit-linear-gradient(top, @color-from 0%, @color-to 100%); // Chrome10+, Safari5.1+
  background-image: -moz-linear-gradient(top, @color-from 0%, @color-to 100%); // FF3.6+
  background-image: -ms-linear-gradient(top, @color-from 0%, @color-to 100%); // IE10+
  background-image: -o-linear-gradient(top, @color-from 0%, @color-to 100%); // Opera 11.10+
  background-image: linear-gradient(to bottom, @color-from 0%, @color-to 100%); // W3C
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{@color-from}', endColorstr='#{@color-to}', GradientType=0); // IE6-9
}

.directional-gradient(@color-from, @color-to, @deg: 45deg) {
  background-color: @color-from; // Old browsers
  background-image: -webkit-gradient(linear, left bottom, right top, color-stop(0%, @color-from), color-stop(100%, @color-to)); // Chrome, Safari4+
  background-image: -webkit-linear-gradient(@deg, @color-from 0%, @color-to 100%); // Chrome10+, Safari5.1+
  background-image: -moz-linear-gradient(@deg, @color-from 0%, @color-to 100%); // FF3.6+
  background-image: -ms-linear-gradient(@deg, @color-from 0%, @color-to 100%); // IE10+
  background-image: -o-linear-gradient(@deg, @color-from 0%, @color-to 100%); // Opera 11.10+
  background-image: linear-gradient(@deg, @color-from 0%, @color-to 100%); // W3C
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{@color-from}', endColorstr='#{@color-to}', GradientType=1); // IE6-9
}

.hairline(@type, @color, @offset) when (@type = single) {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='1'><rect fill='#{@color}' x='0' y='0' width='100%' height='0.5'/></svg>");
  background-position: @offset 100%;
}

.hairline(@type, @color, @offset) when (@type = double) {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='1'><rect fill='#{@color}' x='0' y='0' width='100%' height='0.5'/></svg>"),
  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='1'><rect fill='#{@color}' x='0' y='0' width='100%' height='0.5'/></svg>");
  background-position: @offset 100%, @offset 0;
  background-repeat: no-repeat;
}

//已删除的mixin
/*.transition(@d) {
    -webkit-transition-duration: @d;
    transition-duration: @d;
}
.delay(@d) {
    -webkit-transition-delay: @d;
    transition-delay: @d;
}
.transform(@t) {
    -webkit-transform: @t;
    transform: @t;
}
.transform-origin(@to) {
    -webkit-transform-origin: @to;
    transform-origin: @to;
}
.translate3d(@x:0, @y:0, @z:0) {
    -webkit-transform: translate3d(@x,@y,@z);
    transform: translate3d(@x,@y,@z);
}
.animation(@a) {
    -webkit-animation: @a;
    animation: @a;
}
.border-box(){
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
.box-shadow(@bs) {
    -webkit-box-shadow: @bs;
    box-shadow: @bs;
}
.animation-name(@name) {
  -webkit-animation-name: @name;
     -moz-animation-name: @name;
          animation-name: @name;
}
.animation-duration(@duration) {
  -webkit-animation-duration: @duration;
     -moz-animation-duration: @duration;
          animation-duration: @duration;
}
.animation-direction(@direction) {
  -webkit-animation-direction: @direction;
     -moz-animation-direction: @direction;
          animation-direction: @direction;
}
*/

// copy from weui

// mobile.less
.setTapColor(@c:rgba(0,0,0,0)) {
  -webkit-tap-highlight-color: @c;
}

// setArrow
._setArrow(@arrowsize, @borderColor, @borderWidth) {
  display: inline-block;
  height: @arrowsize;
  width: @arrowsize;
  border-width: @borderWidth @borderWidth 0 0;
  border-color: @borderColor;
  border-style: solid;
}

.setArrow(@direction, @arrowsize, @borderColor, @borderWidth) when (@direction = top) {
  ._setArrow(@arrowsize, @borderColor, @borderWidth);
  transform: matrix(0.71, -0.71, 0.71, 0.71, 0, 0); // rotate(-45deg)
}

.setArrow(@direction, @arrowsize, @borderColor,@borderWidth) when (@direction = right) {
  ._setArrow(@arrowsize, @borderColor, @borderWidth);
  transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0); // rotate(45deg);

  position: relative;
  top: -2px;
}

.setArrow(@direction, @arrowsize, @borderColor,@borderWidth) when (@direction = down) {
  ._setArrow(@arrowsize, @borderColor, @borderWidth);
  transform: matrix(-0.71, 0.71, -0.71, -0.71, 0, 0); // rotate(135deg);

  position: relative;
  top: -3px;
}

.setArrow(@direction, @arrowsize, @borderColor,@borderWidth) when (@direction = left) {
  ._setArrow(@arrowsize, @borderColor, @borderWidth);
  transform: matrix(-0.71, -0.71, 0.71, -0.71, 0, 0); // rotate(-135deg);

  position: relative;
  top: -2px;
}

// test.less

.ellipsis(@w:auto) {
  width: @w;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-wrap: normal;
}

.ellipsisLn(@line) {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: @line;
}

.text_wrap() {
  word-wrap: break-word;
  word-break: break-all;
}

.hyphens() {
  word-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
}